package io.renren.service.impl;

import io.renren.dao.ExcelDao;
import io.renren.dao.CrlgDao;
import io.renren.entity.CrlgDemoEntity;
import io.renren.entity.ExcelDemoEntity;
import io.renren.entity.ExeclFileEntity;
import io.renren.service.ExcelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 实现类
 *
 * @author 阿健
 * @create 2017-03-06 22:17
 */
@Service
public class ExcelServiceImpl implements ExcelService {

    @Autowired
    private ExcelDao excelDao;

    @Autowired
    private CrlgDao crlgDao;

    @Override
    public void saveList(List<ExcelDemoEntity> list, ExeclFileEntity execlFileEntity,String fileName){
//        for (ExcelDemoEntity excelDemoEntity : list) {
        //储存删除的list里面的i
        List<Integer>  deleteList = new ArrayList<>();
        //储存需要添加的list
        List<ExcelDemoEntity>  addList = new ArrayList<>();
        for(int i = 0;i < list.size(); i ++){
            ExcelDemoEntity excelDemoEntity = list.get(i);

            //同笔订单，补齐数据。
            if(excelDemoEntity.getProvince() == null){
                for(int jj = i-1;jj < list.size(); jj ++) {
                    ExcelDemoEntity betEntity = new ExcelDemoEntity();
//                找到需要合并的那个。。没找到有单号的就一直往回溯呢。
                    for (int kk = jj; kk >= 0; kk--) {
                        if (list.get(kk).getProvince() != null) {
                            betEntity = list.get(kk);
                            break;
                        }
                    }
                    //无糖食品。 木糖醇
                    if(excelDemoEntity.getGoodsmoeny()!=null){
                        excelDemoEntity.setGoodsmoeny(excelDemoEntity.getGoodsmoeny().replace("元",""));
                    }
//                    excelDemoEntity.setMoney(excelDemoEntity.getGoodsmoeny());
//                    betEntity.setMoney(String.valueOf(Double.parseDouble(betEntity.getMoney()) - Double.parseDouble(excelDemoEntity.getGoodsmoeny())));


                    betEntity.setIshedan("单笔合单"+excelDemoEntity.getOrdercode());
                    excelDemoEntity.setIshedan("单笔合单"+excelDemoEntity.getOrdercode());

                    excelDemoEntity.setPayDate(betEntity.getPayDate());
                    excelDemoEntity.setName(betEntity.getName());
                    excelDemoEntity.setOrdercode(betEntity.getOrdercode());
                    excelDemoEntity.setProvince(betEntity.getProvince());
                    excelDemoEntity.setExpress(betEntity.getExpress());

                    excelDemoEntity.setPayTime(betEntity.getPayTime());
                    excelDemoEntity.setOrderTime(betEntity.getOrderTime());
                    excelDemoEntity.setProvince(betEntity.getProvince());
                    excelDemoEntity.setPhone(betEntity.getPhone());
                    excelDemoEntity.setAddress(betEntity.getAddress());
                    excelDemoEntity.setBuyName(betEntity.getBuyName());
                    break;
                }
            }


            excelDemoEntity.setExcelId(execlFileEntity.getId());
            excelDemoEntity.setDate(new Date());
            excelDemoEntity.setEditDate(new Date());
            // 如果有特殊的逻辑，应该在这里处理，
            // 例如公式计算等等
            // 获取商品名称,
            String name = excelDemoEntity.getGoods();
            //根据省份来计算运费。先默认申通，

            String goods = excelDemoEntity.getGoods();
            String goodsId = excelDemoEntity.getGoodsId()==null?"":excelDemoEntity.getGoodsId();
            DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            DateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");
            if(excelDemoEntity.getProvince()!=null){
                if(excelDemoEntity.getExpress().contains("申通")){
                    excelDemoEntity.setExpress("申通");
                }
            }
            try {
                if(excelDemoEntity.getPayTime()!=null){
                    excelDemoEntity.setPayDate(format.parse(excelDemoEntity.getPayTime()));
                }
            } catch (ParseException e) {
                e.printStackTrace();
            }




            String province = excelDemoEntity.getProvince();
            if(excelDemoEntity.getGoodsmoeny()!=null){
                excelDemoEntity.setGoodsmoeny(excelDemoEntity.getGoodsmoeny().replace("元",""));
            }
            if(excelDemoEntity.getName()!=null&&excelDemoEntity.getName().length()>20){
                excelDemoEntity.setName(excelDemoEntity.getName().substring(0,20));
            }
            if(excelDemoEntity.getGoods()!="删除"){
                excelDemoEntity.setSheetnum("1");//，默认第一个表格
            }
            if(fileName.contains("淘宝")){
                excelDemoEntity.setSheet("淘宝");


                //淘宝
                if(!goodsId.equals("删除")){

                    if(excelDemoEntity.getProvince()!=null){
                        if("新疆维吾尔自治区 西藏自治区".contains(province)){
                            excelDemoEntity.setExpress("EMS");
                            excelDemoEntity.setRemarks("新疆西藏");
                        }
//                        if("西藏自治区".contains(province)){
//                            excelDemoEntity.setExpress("ems");
//                        }
//                        if("新疆维吾尔自治区".contains(province)&&format2.format(new Date()).compareTo("2018-01-01")<0){
//                            excelDemoEntity.setExpress("ems");
//                            excelDemoEntity.setRemarks("新疆不发");
//                        }
//                        //goodsId.equals("HGGT25kgT")||goodsId.equals("HGGT25KG*1")
//                        if("北京".contains(province)&&!goodsId.contains("25kg")&&!goodsId.contains("25KG")&&format2.format(new Date()).compareTo("2018-01-01")<0){
//                            excelDemoEntity.setRemarks("北京不发");
//                        }

                    }


                    if(goodsId.equals("HGMTC300gD")){

                        excelDemoEntity.setG300(String.valueOf(excelDemoEntity.getNumber()));

//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG300())*0.3);

                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }


                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }


                    }else if(goodsId.equals("HGMTC300g2D")){
                        excelDemoEntity.setG300(String.valueOf(excelDemoEntity.getNumber()*2));

//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG300())*0.3);

//                        if(excelDemoEntity.getWeight()>=1.0){
//                            excelDemoEntity.setG6("10");
//                        }else{
//                            excelDemoEntity.setG6("5");
//                        }
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }


                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }


                    }else if(goodsId.equals("HGMTC550g*1")||goodsId.equals("HGMTC550gD")){

                        if(excelDemoEntity.getNumber()==2||excelDemoEntity.getNumber()==3){
                            excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()));
//                            excelDemoEntity.setG180("1");
                            excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG550())*0.5);
                        }else{
                            excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber() + (int)(Math.rint(excelDemoEntity.getNumber()/4))));
                            excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG550())*0.5);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }

                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }

                    }else if(goodsId.equals("HGMTC500gD")){

//                        //买4送1带
                        excelDemoEntity.setG500(String.valueOf(excelDemoEntity.getNumber() + (int)(Math.rint(excelDemoEntity.getNumber()/4))));
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG500())*0.5);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }

                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }


                    }else if(goodsId.equals("HGMTC500gP")){

                        if( excelDemoEntity.getNumber()>=4){
                            excelDemoEntity.setG380(String.valueOf((int)(Math.rint(excelDemoEntity.getNumber()/4))));
                            excelDemoEntity.setU500(String.valueOf(excelDemoEntity.getNumber()));
                            excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getU500())*0.5+Integer.parseInt(excelDemoEntity.getG380())*0.38);
                            excelDemoEntity.setG56("2");
                            if(excelDemoEntity.getProvince()!=null){
                                excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                            }else{
                                excelDemoEntity.setPostage(0);
                            }

                            excelDemoEntity.setExpress("申通");

                        }else{
                            if(excelDemoEntity.getNumber()==2||excelDemoEntity.getNumber()==3){
                                excelDemoEntity.setG180("1");
                                excelDemoEntity.setU500(String.valueOf(excelDemoEntity.getNumber()));
//                                excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getU500())*0.5);
                                excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getU500())*0.5+Integer.parseInt(excelDemoEntity.getG180())*0.18);
                                excelDemoEntity.setG56("2");
                            }else{
                                excelDemoEntity.setU500(String.valueOf(excelDemoEntity.getNumber()));
                                //重量需要多个相加
                                excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getU500())*0.5);
                                excelDemoEntity.setG56("1");
                            }

                            if(excelDemoEntity.getProvince()!=null){
                                excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                            }else{
                                excelDemoEntity.setPostage(0);
                            }
                            if(excelDemoEntity.getProvince()!=null){
                                if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                    excelDemoEntity.setExpress("EMS");
                                }else{
                                    excelDemoEntity.setExpress("申通");
                                }
                            }

                        }

//                        excelDemoEntity.setU500(String.valueOf(excelDemoEntity.getNumber()));
////                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()));
//                        //重量需要多个相加
//                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getU500())*0.5);
//                        if(excelDemoEntity.getWeight()>=1.0){
//                            excelDemoEntity.setG6("10");
//                        }else{
//                            excelDemoEntity.setG6("5");
//                        }
//                        if(excelDemoEntity.getProvince()!=null){
//                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
//                        }else{
//                            excelDemoEntity.setPostage(0);
//                        }
//                        if(excelDemoEntity.getProvince()!=null){
//                            if(excelDemoEntity.getExpress().contains("申通")){
//                                excelDemoEntity.setExpress("申通");
//                            }else{
//                                excelDemoEntity.setExpress("EMS");
//                            }
//                        }
                    }else if(goodsId.equals("HGSQM500g")){
                        excelDemoEntity.setS500(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加，先加上吧。
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getS500())*0.5);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }

                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                        excelDemoEntity.setSheetnum("3");
                        excelDemoEntity.setRemarks("禾甘");
                    }else if(goodsId.equals("HGMTC156gH")){

                        excelDemoEntity.setG156(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG156())*0.15);


                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }

                    }else if(goodsId.contains("HGMTC6g100S")){
                        excelDemoEntity.setG56(String.valueOf(excelDemoEntity.getNumber()*100));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG56())*0.006);

                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }

                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                        //
                    }else if(goodsId.equals("HGMTC200gD")){

                        excelDemoEntity.setG200(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG200())*0.2);

                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }

                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }

                    }else if(goodsId.equals("HGMTC200g2D")){
                        excelDemoEntity.setG200(String.valueOf(excelDemoEntity.getNumber()*2));

//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG200())*0.2);

                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }


                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }


                    }else if(goodsId.equals("HGMTCZH1000gD")){
//                    }else if(goodsId.equals("HGMTC200gx5D")){
                        excelDemoEntity.setG200(String.valueOf(excelDemoEntity.getNumber()));
                        excelDemoEntity.setG300(String.valueOf(excelDemoEntity.getNumber()));
                        excelDemoEntity.setG500(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()*3));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber());

//                        excelDemoEntity.setG200(String.valueOf(excelDemoEntity.getNumber()*5));
//                        //重量需要多个相加
//                        excelDemoEntity.setWeight(excelDemoEntity.getNumber());

                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }

                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }


                    }else if(goodsId.contains("HGMTCZH1110gD")){
                        excelDemoEntity.setG180(String.valueOf(excelDemoEntity.getNumber()));
                        excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber()));
                        excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()*3));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*1.06);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }

                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }



                    }else if(goodsId.equals("HGMTC200g+300g2D")){
                        excelDemoEntity.setG200(String.valueOf(excelDemoEntity.getNumber()*2));
                        excelDemoEntity.setG300(String.valueOf(excelDemoEntity.getNumber()*2));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber());

//                        excelDemoEntity.setG200(String.valueOf(excelDemoEntity.getNumber()*5));
//                        //重量需要多个相加
//                        excelDemoEntity.setWeight(excelDemoEntity.getNumber());

                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }

                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }


                    }else if(goodsId.equals("HGGT25kgT")||goodsId.equals("HGGT25KG*1")){
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("中铁");
                            }
                        }
                        excelDemoEntity.setKg25(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getKg25())*27);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countCrlg(excelDemoEntity));
                        }


                        excelDemoEntity.setSheetnum("2");
                    }else if(goodsId.equals("HGGT25kgY")){
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("中铁");
                            }
                        }
                        excelDemoEntity.setKgy25(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getKgy25())*27);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countCrlg(excelDemoEntity));
                        }
                        excelDemoEntity.setSheetnum("2");
                    }else if(goodsId.equals("HGGT2.3kgP")){
                        excelDemoEntity.setKg2(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setExpress("申通");
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getKg2())*2.3);
//                        if(excelDemoEntity.getProvince()!=null){
//                            if(!("江苏省 浙江省 上海 安徽省".contains(province)) && excelDemoEntity.getWeight()>15){
//                                excelDemoEntity.setExpress("EMS");
//                            }
//                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        excelDemoEntity.setSheetnum("2");
                    }else if(goodsId.equals("HGMTC380gD")||goodsId.equals("HGMTC380g")){
                            excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber() + ((int) (Math.rint(excelDemoEntity.getNumber() / 3))*1)));
                            excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG380()) * 0.38);

                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }

                            if (excelDemoEntity.getProvince() != null) {
                                excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(), excelDemoEntity.getWeight(), excelDemoEntity.getExpress(), excelDemoEntity));
                            } else {
                                excelDemoEntity.setPostage(0);
                            }

                            if (excelDemoEntity.getProvince() != null) {
                                if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                    excelDemoEntity.setExpress("EMS");
                                }else{
                                    excelDemoEntity.setExpress("申通");
                                }
                            }
                    }else{
                        //大果糖，先不做
                    }
                }

                //自己看下
//                if(excelDemoEntity.getProvince()!=null){
//                    if("云南省 海南省 青海省 宁夏回族自治区 甘肃省 内蒙古自治区 新疆维吾尔自治区 西藏自治区".contains(province)){
//                        excelDemoEntity.setRemarks("四五区");
//                    }
//                }




            }else if(fileName.contains("京东")){
                excelDemoEntity.setSheet("京东新店");
                if(excelDemoEntity.getProvince()!=null) {
                    if ("新疆维吾尔自治区 西藏自治区".contains(province)) {
                        excelDemoEntity.setExpress("EMS");
                        excelDemoEntity.setRemarks("新疆西藏");
                    }
                }

                if(goodsId.equals("HGMTC380gD")||goodsId.equals("HGMTC380g")){
                    if(Double.parseDouble(excelDemoEntity.getGoodsmoeny()) > 0.1) {
                        excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber() + (int) (Math.rint(excelDemoEntity.getNumber() / 3))));
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG380()) * 0.38);

                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }

                        if (excelDemoEntity.getProvince() != null) {
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(), excelDemoEntity.getWeight(), excelDemoEntity.getExpress(), excelDemoEntity));
                        } else {
                            excelDemoEntity.setPostage(0);
                        }

                        if (excelDemoEntity.getProvince() != null) {
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else{
                        excelDemoEntity.setGoodsmoeny("0");
                        excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber()));
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG380()) * 0.38);

                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }

                        if (excelDemoEntity.getProvince() != null) {
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(), excelDemoEntity.getWeight(), excelDemoEntity.getExpress(), excelDemoEntity));
                        } else {
                            excelDemoEntity.setPostage(0);
                        }

                        if (excelDemoEntity.getProvince() != null) {
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }
                }else if(goodsId.equals("HGMTC500gP")){

                    if( excelDemoEntity.getNumber()>=4){
                        excelDemoEntity.setG380(String.valueOf((int)(Math.rint(excelDemoEntity.getNumber()/4))));
                        excelDemoEntity.setU500(String.valueOf(excelDemoEntity.getNumber()));
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getU500())*0.5+Integer.parseInt(excelDemoEntity.getG380())*0.38);
                        excelDemoEntity.setG56("2");
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }

                        excelDemoEntity.setExpress("申通");

                    }else{
                        if(excelDemoEntity.getNumber()==2||excelDemoEntity.getNumber()==3){
                            excelDemoEntity.setG180("1");
                            excelDemoEntity.setU500(String.valueOf(excelDemoEntity.getNumber()));
                            excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getU500())*0.5+Integer.parseInt(excelDemoEntity.getG180())*0.18);
//                            excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getU500())*0.5);
                            excelDemoEntity.setG56("2");
                        }else{
                            excelDemoEntity.setU500(String.valueOf(excelDemoEntity.getNumber()));
                            //重量需要多个相加
                            excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getU500())*0.5);
                            excelDemoEntity.setG56("1");
                        }

                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }

                    }
                }else if(goodsId.contains("HGMTCZH1110gD")){
                    excelDemoEntity.setG180(String.valueOf(excelDemoEntity.getNumber()));
                    excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber()));
                    excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()*3));
                    //重量需要多个相加
                    excelDemoEntity.setWeight(excelDemoEntity.getNumber()*1.06);
                    if(excelDemoEntity.getNumber()==1){
                        excelDemoEntity.setG56("1");
                    }else{
                        excelDemoEntity.setG56("2");
                    }
                    if(excelDemoEntity.getProvince()!=null){
                        excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                    }

                    if(excelDemoEntity.getProvince()!=null){
                        if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                            excelDemoEntity.setExpress("EMS");
                        }else{
                            excelDemoEntity.setExpress("申通");
                        }
                    }



                }else if(goodsId.equals("HGMTC180gD")){
                    if(Double.parseDouble(excelDemoEntity.getGoodsmoeny()) > 0.1) {
                        excelDemoEntity.setG180(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG180())*0.18);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }

                    }else{
                        excelDemoEntity.setGoodsmoeny("0");
                        excelDemoEntity.setG180(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG180())*0.18);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }

                }
                else if(goodsId.equals("HGMTC550G*4")){

                    excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()*4));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()));
                    //重量需要多个相加
                    excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG550())*0.5);
                    if(excelDemoEntity.getNumber()==1){
                        excelDemoEntity.setG56("1");
                    }else{
                        excelDemoEntity.setG56("2");
                    }
                    if(excelDemoEntity.getProvince()!=null){
                        excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                    }else{
                        excelDemoEntity.setPostage(0);
                    }
                    if(excelDemoEntity.getProvince()!=null){
                        if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                            excelDemoEntity.setExpress("EMS");
                        }else{
                            excelDemoEntity.setExpress("申通");
                        }
                    }

                }else if(goodsId.equals("HGMTC550g*1")){

                    if(excelDemoEntity.getNumber()==2||excelDemoEntity.getNumber()==3){
                        excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG180("1");
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG550())*0.5);
                    }else{
                        excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber() + (int)(Math.rint(excelDemoEntity.getNumber()/4))));
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG550())*0.5);
                    }
                    if(excelDemoEntity.getProvince()!=null){
                        if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                            excelDemoEntity.setExpress("EMS");
                        }else{
                            excelDemoEntity.setExpress("申通");
                        }
                    }

                    if(excelDemoEntity.getNumber()==1){
                        excelDemoEntity.setG56("1");
                    }else{
                        excelDemoEntity.setG56("2");
                    }
                    if(excelDemoEntity.getProvince()!=null){
                        excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                    }else{
                        excelDemoEntity.setPostage(0);
                    }

                }

                //无糖食品，红豆薏米，桂圆红枣，冬瓜荷叶，
                else if(goodsId.contains("HGYM200g")||goodsId.contains("HGHDYM200G")){
                    excelDemoEntity.setSheetnum("3");
                    if(Double.parseDouble(excelDemoEntity.getGoodsmoeny()) > 0.1) {
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setRedbean(String.valueOf(1));
                        }else if(excelDemoEntity.getNumber()==2){
                            excelDemoEntity.setRedbean(String.valueOf(3));
                        }else if(excelDemoEntity.getNumber()==3){
                            excelDemoEntity.setRedbean(String.valueOf(5));
                        }else if(excelDemoEntity.getNumber()==4){
                            excelDemoEntity.setRedbean(String.valueOf(6));
                        }else if(excelDemoEntity.getNumber()==5){
                            excelDemoEntity.setRedbean(String.valueOf(8));
                        }else{
                            excelDemoEntity.setRedbean(String.valueOf(excelDemoEntity.getNumber()+excelDemoEntity.getNumber()/2));
                        }
//                        excelDemoEntity.setRedbean(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getRedbean())*0.2);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else{
                        excelDemoEntity.setGoodsmoeny("0");
                        excelDemoEntity.setRedbean(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getRedbean())*0.2);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }

                }else if(goodsId.contains("HGGGF500g")){
                    if(Double.parseDouble(excelDemoEntity.getGoodsmoeny()) > 0.1) {
                        excelDemoEntity.setSheetnum("3");
                        excelDemoEntity.setLongan(String.valueOf(excelDemoEntity.getNumber()+excelDemoEntity.getNumber()/2));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getLongan())*0.5);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }

                    }else{
                        excelDemoEntity.setGoodsmoeny("0");
                        excelDemoEntity.setSheetnum("3");
                        excelDemoEntity.setLongan(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getLongan())*0.5);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }

                }else if(goodsId.contains("HGDGHY160g")||goodsId.contains("HGDG160g")){
                    excelDemoEntity.setSheetnum("3");
                    if(Double.parseDouble(excelDemoEntity.getGoodsmoeny()) > 0.1) {

                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setWax(String.valueOf(1));
                        }else if(excelDemoEntity.getNumber()==2){
                            excelDemoEntity.setWax(String.valueOf(3));
                        }else if(excelDemoEntity.getNumber()==3){
                            excelDemoEntity.setWax(String.valueOf(5));
                        }else if(excelDemoEntity.getNumber()==4){
                            excelDemoEntity.setWax(String.valueOf(6));
                        }else if(excelDemoEntity.getNumber()==5){
                            excelDemoEntity.setWax(String.valueOf(8));
                        }else{
                            excelDemoEntity.setWax(String.valueOf(excelDemoEntity.getNumber()*2));
                            excelDemoEntity.setRemarks("自行修改");
                        }
//                        excelDemoEntity.setWax(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getWax())*0.2);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }

                    }else{
                        excelDemoEntity.setGoodsmoeny("0");
                        excelDemoEntity.setWax(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getWax())*0.2);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }

                }else if(goodsId.contains("HGMYZ350g")||goodsId.contains("HGMYZ350g")){
                    //代餐粥

                    if(Double.parseDouble(excelDemoEntity.getGoodsmoeny()) > 0.1) {
                        excelDemoEntity.setSheetnum("3");
//                        excelDemoEntity.setDcz(String.valueOf(excelDemoEntity.getNumber()*2));
                        excelDemoEntity.setDcz(String.valueOf((int)(Math.rint(excelDemoEntity.getNumber()/2))+excelDemoEntity.getNumber()));
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getDcz())*0.35);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else{
                        excelDemoEntity.setDcz(String.valueOf((int)(Math.rint(excelDemoEntity.getNumber()/2))+excelDemoEntity.getNumber()));
//                        excelDemoEntity.setDcz(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getDcz())*0.35);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                        excelDemoEntity.setSheetnum("3");
                        excelDemoEntity.setGoodsmoeny("0");
                    }


                }else if(goodsId.contains("HGHZM300g")||goodsId.contains("HGHZM300g")){
                    //核桃粉
                    if(Double.parseDouble(excelDemoEntity.getGoodsmoeny()) > 0.1) {
                        excelDemoEntity.setSheetnum("3");
                        excelDemoEntity.setHtf(String.valueOf(excelDemoEntity.getNumber()*2));
                        if(Double.parseDouble(excelDemoEntity.getGoodsmoeny()) > 10){
                            excelDemoEntity.setHtf(String.valueOf((int)(Math.rint(excelDemoEntity.getNumber()/2))+excelDemoEntity.getNumber()));
//                            excelDemoEntity.setHtf(String.valueOf(excelDemoEntity.getNumber()));
                        }else{
                            excelDemoEntity.setHtf(String.valueOf(excelDemoEntity.getNumber()));
                        }
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getHtf())*0.3);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                        excelDemoEntity.setSheetnum("3");

                    }else{
                        excelDemoEntity.setGoodsmoeny("0");
                        excelDemoEntity.setSheetnum("3");
                        excelDemoEntity.setHtf(String.valueOf(excelDemoEntity.getNumber()*2));
                        if(Double.parseDouble(excelDemoEntity.getGoodsmoeny()) > 10){
                            excelDemoEntity.setHtf(String.valueOf((int)(Math.rint(excelDemoEntity.getNumber()/2))+excelDemoEntity.getNumber()));
//                            excelDemoEntity.setHtf(String.valueOf(excelDemoEntity.getNumber()));
                        }else{
                            excelDemoEntity.setHtf(String.valueOf(excelDemoEntity.getNumber()));
                        }
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getHtf())*0.3);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                        excelDemoEntity.setSheetnum("3");
                    }



                }else if(goodsId.contains("HGSQM500g")){
                    excelDemoEntity.setS500(String.valueOf(excelDemoEntity.getNumber()));
                    //重量需要多个相加
                    excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getS500())*0.5);
                    if(excelDemoEntity.getProvince()!=null){
                        excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                    }else{
                        excelDemoEntity.setPostage(0);
                    }
                    if(excelDemoEntity.getProvince()!=null){
                        if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                            excelDemoEntity.setExpress("EMS");
                        }else{
                            excelDemoEntity.setExpress("申通");
                        }
                    }
                    excelDemoEntity.setSheetnum("3");
                }

                else if(goodsId.contains("HGSQM500g*2")){
                    excelDemoEntity.setS500(String.valueOf(excelDemoEntity.getNumber()*2));
                    //重量需要多个相加
                    excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getS500())*1);
                    if(excelDemoEntity.getProvince()!=null){
                        excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                    }else{
                        excelDemoEntity.setPostage(0);
                    }
                    if(excelDemoEntity.getProvince()!=null){
                        if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                            excelDemoEntity.setExpress("EMS");
                        }else{
                            excelDemoEntity.setExpress("申通");
                        }
                    }
                    excelDemoEntity.setSheetnum("3");
                }


                //新款结束
                else if(goodsId.equals("HGMTC156gH")){

                    excelDemoEntity.setG156(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()));
                    //重量需要多个相加
                    excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG156())*0.15);
                    if(excelDemoEntity.getNumber()==1){
                        excelDemoEntity.setG56("1");
                    }else{
                        excelDemoEntity.setG56("2");
                    }
                    if(excelDemoEntity.getProvince()!=null){
                        excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                    }else{
                        excelDemoEntity.setPostage(0);
                    }
                    if(excelDemoEntity.getProvince()!=null){
                        if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                            excelDemoEntity.setExpress("EMS");
                        }else{
                            excelDemoEntity.setExpress("申通");
                        }
                    }

                }
                else if(goodsId.equals("HGGT25kgT")||goodsId.equals("HGGT25KG*1")){
                    if(excelDemoEntity.getProvince()!=null){
                        if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                            excelDemoEntity.setExpress("EMS");
                        }else{
                            excelDemoEntity.setExpress("中铁");
                        }
                    }
                    excelDemoEntity.setKg25(String.valueOf(excelDemoEntity.getNumber()));
                    //重量需要多个相加
                    excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getKg25())*27);
                    if(excelDemoEntity.getProvince()!=null){
                        excelDemoEntity.setPostage(countCrlg(excelDemoEntity));
                    }


                    excelDemoEntity.setSheetnum("2");
                }else if(goodsId.equals("HGGT25kgY")){
                    if(excelDemoEntity.getProvince()!=null){
                        if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                            excelDemoEntity.setExpress("EMS");
                        }else{
                            excelDemoEntity.setExpress("中铁");
                        }
                    }
                    excelDemoEntity.setKgy25(String.valueOf(excelDemoEntity.getNumber()));
                    //重量需要多个相加
                    excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getKgy25())*27);
                    if(excelDemoEntity.getProvince()!=null){
                        excelDemoEntity.setPostage(countCrlg(excelDemoEntity));
                    }
                    excelDemoEntity.setSheetnum("2");
                }else if(goodsId.equals("HGGT2.3kgP")){
                    excelDemoEntity.setKg2(String.valueOf(excelDemoEntity.getNumber()));
                    //重量需要多个相加
                    excelDemoEntity.setExpress("申通");
                    excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getKg2())*2.3);
//                    if(excelDemoEntity.getProvince()!=null){
//                        if(!("江苏省 浙江省 上海 安徽省".contains(province)) && excelDemoEntity.getWeight()>15){
//                            excelDemoEntity.setExpress("EMS");
//                        }
//                    }
                    if(excelDemoEntity.getProvince()!=null){
                        excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                    }else{
                        excelDemoEntity.setPostage(0);
                    }
                    excelDemoEntity.setSheetnum("2");


                }else{
                    //大果糖，先不做
                }

            }else if(fileName.contains("万春")){
                excelDemoEntity.setSheet("万春");
                if(excelDemoEntity.getProvince()!=null) {
                    if ("新疆维吾尔自治区 西藏自治区".contains(province)) {
                        excelDemoEntity.setExpress("EMS");
                        excelDemoEntity.setRemarks("新疆西藏");
                    }
                }
                //无糖食品，红豆薏米，桂圆红枣，冬瓜荷叶，
                if(goodsId.contains("HGYM200g")||goodsId.contains("HGHDYM200G")){

                    if(excelDemoEntity.getNumber()==1){
                        excelDemoEntity.setRedbean(String.valueOf(1));
                    }else if(excelDemoEntity.getNumber()==2){
                        excelDemoEntity.setRedbean(String.valueOf(3));
                    }else if(excelDemoEntity.getNumber()==3){
                        excelDemoEntity.setRedbean(String.valueOf(5));
                    }else if(excelDemoEntity.getNumber()==4){
                        excelDemoEntity.setRedbean(String.valueOf(6));
                    }else if(excelDemoEntity.getNumber()==5){
                        excelDemoEntity.setRedbean(String.valueOf(8));
                    }else{
                        excelDemoEntity.setRedbean(String.valueOf(excelDemoEntity.getNumber()+excelDemoEntity.getNumber()/2));
                        excelDemoEntity.setRemarks("自行修改");
                    }

//                    excelDemoEntity.setRedbean(String.valueOf(excelDemoEntity.getNumber()*2));
                    //重量需要多个相加
                    excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getRedbean())*0.3);
                    if(excelDemoEntity.getProvince()!=null){
                        excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                    }else{
                        excelDemoEntity.setPostage(0);
                    }
                    if(excelDemoEntity.getProvince()!=null){
                        if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                            excelDemoEntity.setExpress("EMS");
                        }else{
                            excelDemoEntity.setExpress("申通");
                        }
                    }
                    excelDemoEntity.setSheetnum("3");
                }else if(goodsId.contains("HGGGF500g")){
                    //桂圆没有买1送1
                    excelDemoEntity.setLongan(String.valueOf(excelDemoEntity.getNumber()+excelDemoEntity.getNumber()/2));
                    //重量需要多个相加
                    excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getLongan())*0.5);
                    if(excelDemoEntity.getProvince()!=null){
                        excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                    }else{
                        excelDemoEntity.setPostage(0);
                    }
                    if(excelDemoEntity.getProvince()!=null){
                        if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                            excelDemoEntity.setExpress("EMS");
                        }else{
                            excelDemoEntity.setExpress("申通");
                        }
                    }
                    excelDemoEntity.setSheetnum("3");
                }else if(goodsId.contains("HGDGHY160g")||goodsId.contains("HGDG160g")){

                    if(excelDemoEntity.getNumber()==1){
                        excelDemoEntity.setWax(String.valueOf(1));
                    }else if(excelDemoEntity.getNumber()==2){
                        excelDemoEntity.setWax(String.valueOf(3));
                    }else if(excelDemoEntity.getNumber()==3){
                        excelDemoEntity.setWax(String.valueOf(5));
                    }else if(excelDemoEntity.getNumber()==4){
                        excelDemoEntity.setWax(String.valueOf(6));
                    }else if(excelDemoEntity.getNumber()==5){
                        excelDemoEntity.setWax(String.valueOf(8));
                    }else{
                        excelDemoEntity.setWax(String.valueOf(excelDemoEntity.getNumber()*2));
                        excelDemoEntity.setRemarks("自行修改");
                    }


//                    excelDemoEntity.setWax(String.valueOf(excelDemoEntity.getNumber()*2));
                    //重量需要多个相加
                    excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getWax())*0.2);
                    if(excelDemoEntity.getProvince()!=null){
                        excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                    }else{
                        excelDemoEntity.setPostage(0);
                    }
                    if(excelDemoEntity.getProvince()!=null){
                        if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                            excelDemoEntity.setExpress("EMS");
                        }else{
                            excelDemoEntity.setExpress("申通");
                        }
                    }
                    excelDemoEntity.setSheetnum("3");
                }else if(goodsId.contains("HGMYZ350g")||goodsId.contains("HGMYZ350g")){
                    //代餐粥
                    excelDemoEntity.setDcz(String.valueOf((int)(Math.rint(excelDemoEntity.getNumber()/2))+excelDemoEntity.getNumber()));
//                    excelDemoEntity.setDcz(String.valueOf(excelDemoEntity.getNumber()));
                    //重量需要多个相加
                    excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getDcz())*0.35);
                    if(excelDemoEntity.getProvince()!=null){
                        excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                    }else{
                        excelDemoEntity.setPostage(0);
                    }
                    if(excelDemoEntity.getProvince()!=null){
                        if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                            excelDemoEntity.setExpress("EMS");
                        }else{
                            excelDemoEntity.setExpress("申通");
                        }
                    }
                    excelDemoEntity.setSheetnum("3");
                }else if(goodsId.contains("HGHZM300g")||goodsId.contains("HGHZM300g")){
                    //核桃粉
                    excelDemoEntity.setHtf(String.valueOf((int)(Math.rint(excelDemoEntity.getNumber()/2))+excelDemoEntity.getNumber()));
//                    excelDemoEntity.setHtf(String.valueOf(excelDemoEntity.getNumber()));
                    //重量需要多个相加
                    excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getHtf())*0.3);
                    if(excelDemoEntity.getProvince()!=null){
                        excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                    }else{
                        excelDemoEntity.setPostage(0);
                    }
                    if(excelDemoEntity.getProvince()!=null){
                        if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                            excelDemoEntity.setExpress("EMS");
                        }else{
                            excelDemoEntity.setExpress("申通");
                        }
                    }
                    excelDemoEntity.setSheetnum("3");
                }else{
                    //大果糖，先不做
                }

            }else{

                //天猫
//                if(!excelDemoEntity.getExpress().contains("1")){
                if(!goodsId.equals("删除")){
                    excelDemoEntity.setSheet("天猫");
                    if(excelDemoEntity.getProvince()!=null){
                        if("新疆维吾尔自治区 西藏自治区".contains(province)){
                            excelDemoEntity.setExpress("EMS");
                            excelDemoEntity.setRemarks("新疆西藏");
                        }
//                        if("西藏自治区".contains(province)){
//                            excelDemoEntity.setExpress("ems");
//                        }
//                        if("新疆维吾尔自治区".contains(province)&&format2.format(new Date()).compareTo("2018-01-01")<0){
//                            excelDemoEntity.setExpress("ems");
//                            excelDemoEntity.setRemarks("新疆不发");
//                        }
//
//                        if("北京".contains(province)&&!goodsId.contains("25kg")&&!goodsId.contains("25KG")&&format2.format(new Date()).compareTo("2018-01-01")<0){
//                            excelDemoEntity.setRemarks("北京不发");
//                        }


                    }


                    if(goodsId.equals("HGMTC500gD")){
//4送1  ，老包装500克
                        excelDemoEntity.setG500(String.valueOf(excelDemoEntity.getNumber() + (int)(Math.rint(excelDemoEntity.getNumber()/4))));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()));
                        //买5免1
//                        excelDemoEntity.setG500(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()-(int)(Math.rint(excelDemoEntity.getNumber()/5))));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG500())*0.5);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
//                        excelDemoEntity.setG500(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()));
//                        //重量需要多个相加
//                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG500())*0.5);
//                        Integer ll=(int)(Math.rint(excelDemoEntity.getNumber()/3));
//                        if(ll!=null&&ll!=0){
//                            excelDemoEntity.setRemarks(Integer.toString(ll));
//                        }
//                        if(excelDemoEntity.getProvince()!=null){
//                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
//                        }else{
//                            excelDemoEntity.setPostage(0);
//                        }
//                        if(excelDemoEntity.getProvince()!=null){
//                            if(excelDemoEntity.getExpress().contains("申通")){
//                                excelDemoEntity.setExpress("申通");
//                            }else{
//                                excelDemoEntity.setExpress("ems");
//                            }
//                        }


                    }else if(goodsId.equals("HGMTC550G*5")){

                        //双11活动单2017//11/9号 10点前。发红豆薏米。
                        excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()*4));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG550())*0.5+excelDemoEntity.getNumber()*0.2);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
//                        excelDemoEntity.setRemarks("冬瓜*"+excelDemoEntity.getNumber());

                        ExcelDemoEntity addFoodDemo = new ExcelDemoEntity();
                        addFoodDemo.setOrdercode(excelDemoEntity.getOrdercode());
                        addFoodDemo.setProvince(excelDemoEntity.getProvince());
                        addFoodDemo.setPhone(excelDemoEntity.getPhone());
                        addFoodDemo.setAddress(excelDemoEntity.getAddress());
                        addFoodDemo.setBuyName(excelDemoEntity.getBuyName());
                        addFoodDemo.setName(excelDemoEntity.getName());
                        addFoodDemo.setExpress(excelDemoEntity.getExpress());
                        addFoodDemo.setMoney("0.00");
                        addFoodDemo.setGoodsmoeny("0.00");
                        addFoodDemo.setGoods("删除");
                        addFoodDemo.setGoodsId("删除");
                        addFoodDemo.setWax(Integer.toString(excelDemoEntity.getNumber()));
                        addFoodDemo.setSheetnum("3");
                        list.add(addFoodDemo);

//                        try {
//                            if(excelDemoEntity.getOrderTime()!=null){
//                                String beginTime=excelDemoEntity.getOrderTime();
//                                String endTime=new String("2017-11-09 10:00:00");
//                                if (format.parse(beginTime).before(format.parse(endTime))){
//                                    excelDemoEntity.setRemarks("薏米*"+excelDemoEntity.getNumber());
//                                }else{
//                                    excelDemoEntity.setRemarks("冬瓜*"+excelDemoEntity.getNumber());
//                                }
//                            }
//                        } catch (ParseException e) {
//                            e.printStackTrace();
//                        }

                    }else if(goodsId.equals("HGMTCZH1000gD")){
                        excelDemoEntity.setG200(String.valueOf(excelDemoEntity.getNumber()));
                        excelDemoEntity.setG300(String.valueOf(excelDemoEntity.getNumber()));
                        excelDemoEntity.setG500(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()*3));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber());
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }

                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }



                    }else if(goodsId.equals("HGMTC300gD")){

                        excelDemoEntity.setG300(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG300())*0.3);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }

                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }



                    }
                    //新款 380 deng
                    else if(goodsId.equals("HGMTC380gD")||goodsId.equals("HGMTC380g")){
//                        if( excelDemoEntity.getNumber()>=5){
//                            excelDemoEntity.setG550(String.valueOf((int)(Math.rint(excelDemoEntity.getNumber()/5))));
//                            excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber()));
////                            excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()));
//                            //重量需要多个相加
//                            excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG380())*0.38 + Integer.parseInt(excelDemoEntity.getG550())*0.55);
//
//                            if(excelDemoEntity.getWeight()>=1.0){
//                                excelDemoEntity.setG6("10");
//                            }else{
//                                excelDemoEntity.setG6("5");
//                            }
//                            if(excelDemoEntity.getProvince()!=null){
//                                excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
//                            }else{
//                                excelDemoEntity.setPostage(0);
//                            }
//                            excelDemoEntity.setExpress("申通");
//
//                        }else{
//                            excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber()));
////                            excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()));
//                            //重量需要多个相加
//                            excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG380())*0.38);
//                            if(excelDemoEntity.getWeight()>=1.0){
//                                excelDemoEntity.setG6("10");
//                            }else{
//                                excelDemoEntity.setG6("5");
//                            }
//                            if(excelDemoEntity.getProvince()!=null){
//                                excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
//                            }else{
//                                excelDemoEntity.setPostage(0);
//                            }
//                            if(excelDemoEntity.getProvince()!=null){
//                                if(excelDemoEntity.getExpress().contains("申通")){
//                                    excelDemoEntity.setExpress("申通");
//                                }else{
//                                    excelDemoEntity.setExpress("ems");
//                                }
//                            }
//                        }


//                        //3.7-3.9、、买7mian2
//                        try {
//                            String beginTime=excelDemoEntity.getOrderTime();
//                            String startTime=new String("2018-03-19 10:00:00");
//                            String endTime=new String("2018-03-25 23:59:59");
//                            if (format.parse(beginTime).after(format.parse(startTime))&&format.parse(beginTime).before(format.parse(endTime))){
//                                excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber()));
//                                excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG380())*0.38);
//                                if(excelDemoEntity.getG380().equals("5")){
//                                    excelDemoEntity.setG380("7");
//                                    excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG380())*0.38);
//                                }
//                            }else{
////                                excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber() + (int)(Math.rint(excelDemoEntity.getNumber()/4))));
//                                excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber()));
//                                excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG380())*0.38);
//                            }
//                        } catch (ParseException e) {
//                            e.printStackTrace();
//                        }

//                        excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber() + (int)(Math.rint(excelDemoEntity.getNumber()/4))));
//                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG380())*0.38);

                        excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber()));
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG380())*0.38);

                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }

                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }

                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }

                    }

                    //新款 380*2
                    else if(goodsId.equals("HGMTC380g*2")){

                        excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber()*2));
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG380())*0.38);


                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }

                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }

                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }

                    }

                    //新款 罐4送380克
                    else if(goodsId.equals("MTCZH006")){

                        excelDemoEntity.setU500(String.valueOf(excelDemoEntity.getNumber()*4));
//                        excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber()*1));
//                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getU500())*0.5+Integer.parseInt(excelDemoEntity.getG380())*0.38);
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getU500())*0.5);

                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }

                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }

                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }


                        excelDemoEntity.setRemarks("冬瓜*"+excelDemoEntity.getNumber());

                        ExcelDemoEntity addFoodDemo = new ExcelDemoEntity();
                        addFoodDemo.setOrdercode(excelDemoEntity.getOrdercode());
                        addFoodDemo.setProvince(excelDemoEntity.getProvince());
                        addFoodDemo.setPhone(excelDemoEntity.getPhone());
                        addFoodDemo.setAddress(excelDemoEntity.getAddress());
                        addFoodDemo.setBuyName(excelDemoEntity.getBuyName());
                        addFoodDemo.setName(excelDemoEntity.getName());
                        addFoodDemo.setExpress(excelDemoEntity.getExpress());
                        addFoodDemo.setMoney("0.00");
                        addFoodDemo.setGoodsmoeny("0.00");
                        addFoodDemo.setGoods("删除");
                        addFoodDemo.setGoodsId("删除");
                        addFoodDemo.setWax(Integer.toString(excelDemoEntity.getNumber()));
                        addFoodDemo.setSheetnum("3");
                        list.add(addFoodDemo);

                    }

                    else if(goodsId.contains("HGMTCZH1110gD")){
                        excelDemoEntity.setG180(String.valueOf(excelDemoEntity.getNumber()));
                        excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber()));
                        excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()*3));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*1.06);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }

                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }



                    }else if(goodsId.equals("HGMTC180gD")){

                        excelDemoEntity.setG180(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG180())*0.18);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }

                    }
                    else if(goodsId.equals("HGMTC550G*4")){


//                        excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()*4));
//                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG550())*0.55);
//                        excelDemoEntity.setG56("");
//                        if(excelDemoEntity.getProvince()!=null){
//                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
//                        }else{
//                            excelDemoEntity.setPostage(0);
//                        }
//                        if(excelDemoEntity.getProvince()!=null){
//                            if(excelDemoEntity.getExpress().contains("申通")){
//                                excelDemoEntity.setExpress("申通");
//                            }else{
//                                excelDemoEntity.setExpress("EMS");
//                            }
//                        }


                        try {
                            //双11活动单2017//11/9号 10点前。发红豆薏米。
                            excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()*4));
                            //重量需要多个相加



                            String beginTime=excelDemoEntity.getPayTime();
                            String beginTimeo=excelDemoEntity.getOrderTime();
                            String startTime=new String("2018-06-01 00:00:00");
                            String endTime=new String("2018-06-20 23:59:59");
                            if ((format.parse(beginTime).after(format.parse(startTime))&&format.parse(beginTime).before(format.parse(endTime)))||
                                    format.parse(beginTimeo).after(format.parse(startTime))&&format.parse(beginTimeo).before(format.parse(endTime))){
                                excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG550())*0.55+excelDemoEntity.getNumber()*0.2);
                                excelDemoEntity.setG56("2");
                                excelDemoEntity.setRemarks("薏米*"+excelDemoEntity.getNumber());

                                ExcelDemoEntity addFoodDemo = new ExcelDemoEntity();
                                addFoodDemo.setOrdercode(excelDemoEntity.getOrdercode());
                                addFoodDemo.setProvince(excelDemoEntity.getProvince());
                                addFoodDemo.setPhone(excelDemoEntity.getPhone());
                                addFoodDemo.setAddress(excelDemoEntity.getAddress());
                                addFoodDemo.setBuyName(excelDemoEntity.getBuyName());
                                addFoodDemo.setName(excelDemoEntity.getName());
                                addFoodDemo.setExpress(excelDemoEntity.getExpress());
                                addFoodDemo.setMoney("0.00");
                                addFoodDemo.setGoodsmoeny("0.00");
                                addFoodDemo.setGoods("删除");
                                addFoodDemo.setGoodsId("删除");
                                addFoodDemo.setRedbean(Integer.toString(excelDemoEntity.getNumber()));
                                addFoodDemo.setSheetnum("3");
                                list.add(addFoodDemo);
                            }else{
                                excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG550())*0.5);
                                if(excelDemoEntity.getNumber()==1){
                                    excelDemoEntity.setG56("1");
                                }else{
                                    excelDemoEntity.setG56("2");
                                }
                            }
                            if(excelDemoEntity.getProvince()!=null){
                                excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                            }else{
                                excelDemoEntity.setPostage(0);
                            }

                            if(excelDemoEntity.getProvince()!=null){
                                if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                    excelDemoEntity.setExpress("EMS");
                                }else{
                                    excelDemoEntity.setExpress("申通");
                                }
                            }

                        }catch (ParseException e) {
                            e.printStackTrace();
                       }





                    }else if(goodsId.equals("HGMTC550g*1")||goodsId.equals("HGMTC550gD")){

                        //3.7-3.9、、买4送1
//                        try {
//                            String beginTime=excelDemoEntity.getOrderTime();
//                            String startTime=new String("2018-03-07 00:00:00");
//                            String endTime=new String("2018-03-09 23:59:59");
//                            if (format.parse(beginTime).after(format.parse(startTime))&&format.parse(beginTime).before(format.parse(endTime))){
//                                excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber() + (int)(Math.rint(excelDemoEntity.getNumber()/4))));
//                            }else{
//                                excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()));
//                            }
//                        } catch (ParseException e) {
//                            e.printStackTrace();
//                        }

                        //买2送180克
                        if(excelDemoEntity.getNumber()==2||excelDemoEntity.getNumber()==3){
                            try {
                                String beginTime=excelDemoEntity.getOrderTime();
                                String startTime=new String("2018-10-16 17:00:00");
                                String endTime=new String("2018-10-16 18:00:00");
                                if (format.parse(beginTime).after(format.parse(startTime))&&format.parse(beginTime).before(format.parse(endTime))){
                                    excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()));
                                    excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG550())*0.5);
                                }else{
                                    excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()));
                                    excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG550())*0.5);
//                                    excelDemoEntity.setG180("1");
//                                    excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG550())*0.5+Integer.parseInt(excelDemoEntity.getG180())*0.18);
                                }

                            } catch (ParseException e) {
//                            e.printStackTrace();
                             }

                        }else{
                            excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber() + (int)(Math.rint(excelDemoEntity.getNumber()/4))));
                            excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG550())*0.5);
                        }

                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }

                        //买2送茶，没4送1，旧活动。
//                        excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber() + (int)(Math.rint(excelDemoEntity.getNumber()/4))));
//                        //excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()));
//                        //重量需要多个相加
//                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG550())*0.55);
//                        if(excelDemoEntity.getProvince()!=null){
//                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
//                                excelDemoEntity.setExpress("EMS");
//                            }else{
//                                excelDemoEntity.setExpress("申通");
//                            }
//                        }
//
//                        try {
//
//                            //6.11-6.13...注意  paytime ,支付时间不一定有。
//                            String beginTime=excelDemoEntity.getPayTime();
//                            String beginTimeo=excelDemoEntity.getOrderTime();
//                            String startTime = new String("2018-07-20 10:00:00");
//                            String endTime = new String("2018-11-15 23:59:59");
////                            if ((format.parse(beginTime).after(format.parse(startTime))&&format.parse(beginTime).before(format.parse(endTime)))||
////                                    format.parse(beginTimeo).after(format.parse(startTime))&&format.parse(beginTimeo).before(format.parse(endTime))){
//                            if ((format.parse(beginTimeo).after(format.parse(startTime))&&format.parse(beginTimeo).before(format.parse(endTime)))&&(excelDemoEntity.getNumber()==2||excelDemoEntity.getNumber()==3)){
//                                excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG550()) * 0.55 + 0.2);
//
//                                excelDemoEntity.setRemarks("冬瓜*1");
//
//                                ExcelDemoEntity addFoodDemo = new ExcelDemoEntity();
//                                addFoodDemo.setOrdercode(excelDemoEntity.getOrdercode());
//                                addFoodDemo.setProvince(excelDemoEntity.getProvince());
//                                addFoodDemo.setPhone(excelDemoEntity.getPhone());
//                                addFoodDemo.setAddress(excelDemoEntity.getAddress());
//                                addFoodDemo.setBuyName(excelDemoEntity.getBuyName());
//                                addFoodDemo.setName(excelDemoEntity.getName());
//                                addFoodDemo.setExpress(excelDemoEntity.getExpress());
//                                addFoodDemo.setMoney("0.00");
//                                addFoodDemo.setGoodsmoeny("0.00");
//                                addFoodDemo.setGoods("删除");
//                                addFoodDemo.setGoodsId("删除");
//                                addFoodDemo.setWax("1");
//                                addFoodDemo.setSheetnum("3");
//                                list.add(addFoodDemo);
//                            }
//                        }catch (ParseException e) {
//                            e.printStackTrace();
//                        }
                        //买2送茶，没4送1，旧活动。


                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
//                        if(excelDemoEntity.getWeight()<=0.55){
//                            excelDemoEntity.setG56("1");
//                        }else{
//                            excelDemoEntity.setG56("2");
//                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }

                    }else if(goodsId.equals("HGMTCZH880g")){

                        excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber()));
                        excelDemoEntity.setU500(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()*2));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*0.88);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }

                    }


                    //新款结束
                    else if(goodsId.equals("HGMTC156gH")){

                        excelDemoEntity.setG156(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG156())*0.15);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }

                    }else if(goodsId.equals("HGMTC200gD")){
                        excelDemoEntity.setG200(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG200())*0.2);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }

                    }else if(goodsId.equals("HGMTCZH1000g")){

                        excelDemoEntity.setG500(String.valueOf(excelDemoEntity.getNumber()));
                        excelDemoEntity.setU500(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()*2));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*1);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }

                    }else if(goodsId.equals("HGMTCZH500gD")){

                        excelDemoEntity.setG200(String.valueOf(excelDemoEntity.getNumber()));
                        excelDemoEntity.setG300(String.valueOf(excelDemoEntity.getNumber()));
//                        excelDemoEntity.setG6(String.valueOf(excelDemoEntity.getNumber()*2));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*0.5);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }

                    }else if(goods.contains("正品包邮 禾甘木糖醇 木糖醇食品 木糖醇糖 无糖食品 5000g 赠品")){
                        excelDemoEntity.setExpress("");

                    }else if(goodsId.equals("HGMTC500gP")){
                        if( excelDemoEntity.getNumber()>=4){
                            excelDemoEntity.setG380(String.valueOf((int)(Math.rint(excelDemoEntity.getNumber()/4))));
                            excelDemoEntity.setU500(String.valueOf(excelDemoEntity.getNumber()));
                            excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getU500())*0.5+Integer.parseInt(excelDemoEntity.getG380())*0.38);
                            excelDemoEntity.setG56("2");
                            if(excelDemoEntity.getProvince()!=null){
                                excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                            }else{
                                excelDemoEntity.setPostage(0);
                            }

                            excelDemoEntity.setExpress("申通");

                        }else{
                            if(excelDemoEntity.getNumber()==2||excelDemoEntity.getNumber()==3){

                                try {
                                    String beginTime=excelDemoEntity.getOrderTime();
                                    String startTime=new String("2018-09-09 00:00:00");
                                    String endTime=new String("2018-09-09 01:00:00");
                                    if (format.parse(beginTime).after(format.parse(startTime))&&format.parse(beginTime).before(format.parse(endTime))){
                                        excelDemoEntity.setU500(String.valueOf(excelDemoEntity.getNumber()));
                                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getU500())*0.5);
                                    }else{
                                        excelDemoEntity.setG180("1");
                                        excelDemoEntity.setU500(String.valueOf(excelDemoEntity.getNumber()));
//                                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getU500())*0.5);
                                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getU500())*0.5+Integer.parseInt(excelDemoEntity.getG180())*0.18);
                                    }

                                } catch (ParseException e) {
                                }

                                excelDemoEntity.setG56("2");
                            }else{
                                excelDemoEntity.setU500(String.valueOf(excelDemoEntity.getNumber()));
                                //重量需要多个相加
                                excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getU500())*0.5);
                                excelDemoEntity.setG56("1");
                            }

                            if(excelDemoEntity.getProvince()!=null){
                                excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                            }else{
                                excelDemoEntity.setPostage(0);
                            }
                            if(excelDemoEntity.getProvince()!=null){
                                if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                    excelDemoEntity.setExpress("EMS");
                                }else{
                                    excelDemoEntity.setExpress("申通");
                                }
                            }

                        }
                    }else if(goodsId.equals("HGSQM500g")){
                        excelDemoEntity.setS500(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getS500())*0.5);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                        excelDemoEntity.setSheetnum("3");
                    }else if(goodsId.contains("HGSQM1000g")){
                        excelDemoEntity.setS500(String.valueOf(excelDemoEntity.getNumber()*2));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getS500())*0.5);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                        excelDemoEntity.setSheetnum("3");
                    }else if(goodsId.contains("HGSQM2000g")){
                        excelDemoEntity.setS500(String.valueOf(excelDemoEntity.getNumber()*4));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getS500())*0.5);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                        excelDemoEntity.setSheetnum("3");
                    }
                    //无糖食品，红豆薏米，桂圆红枣，冬瓜荷叶，
                    else if(goodsId.contains("HGYM200g")||goodsId.contains("HGHDYM200G")){
                        if(Double.parseDouble(excelDemoEntity.getGoodsmoeny()) > 10){
                            excelDemoEntity.setRedbean(String.valueOf((int)(Math.rint(excelDemoEntity.getNumber()/2))+excelDemoEntity.getNumber()));
                        }else{
                            excelDemoEntity.setRedbean(String.valueOf(excelDemoEntity.getNumber()));
                        }

                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getRedbean())*0.3);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                        excelDemoEntity.setSheetnum("3");
                    }else if(goodsId.contains("HGGGF500g")){
                        //桂圆
                        try {
                            String beginTime=excelDemoEntity.getOrderTime();
                            String startTime=new String("2018-09-09 00:00:00");
                            String endTime=new String("2018-09-11 00:00:00");
                            if (format.parse(beginTime).after(format.parse(startTime))&&format.parse(beginTime).before(format.parse(endTime))){
                                excelDemoEntity.setLongan(String.valueOf(excelDemoEntity.getNumber()));
                            }else{
                                excelDemoEntity.setLongan(String.valueOf(excelDemoEntity.getNumber()+excelDemoEntity.getNumber()/2));
                            }

                        } catch (ParseException e) {
                        }

//                        excelDemoEntity.setLongan(String.valueOf(excelDemoEntity.getNumber()+excelDemoEntity.getNumber()/2));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getLongan())*0.5);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                        excelDemoEntity.setSheetnum("3");
                    }else if(goodsId.contains("HGGGFD500*2")){
                        excelDemoEntity.setLongan(String.valueOf(excelDemoEntity.getNumber()+excelDemoEntity.getNumber()*2));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getLongan())*0.5);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                        excelDemoEntity.setSheetnum("3");
                    }else if(goodsId.contains("HGDGHY160g")||goodsId.contains("HGDG160g")){
                        excelDemoEntity.setWax(String.valueOf(excelDemoEntity.getNumber()*2));
                        if(Double.parseDouble(excelDemoEntity.getGoodsmoeny()) > 10){
                            excelDemoEntity.setWax(String.valueOf((int)(Math.rint(excelDemoEntity.getNumber()/2))+excelDemoEntity.getNumber()));
                        }else{
                            excelDemoEntity.setWax(String.valueOf(excelDemoEntity.getNumber()));
                        }
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getWax())*0.2);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                        excelDemoEntity.setSheetnum("3");
                    }else if(goodsId.contains("HGMYZ350g")||goodsId.contains("HGMYZ350g")){
                        //代餐粥
                        excelDemoEntity.setDcz(String.valueOf((int)(Math.rint(excelDemoEntity.getNumber()/2))+excelDemoEntity.getNumber()));
//                        excelDemoEntity.setDcz(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加

                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getDcz())*0.35);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                        excelDemoEntity.setSheetnum("3");
                    }else if(goodsId.contains("MYDCZ350g*4")){
                        //代餐粥
//                        excelDemoEntity.setDcz(String.valueOf((int)(Math.rint(excelDemoEntity.getNumber()/2))+excelDemoEntity.getNumber()));
                        excelDemoEntity.setDcz(String.valueOf((int)(Math.rint(excelDemoEntity.getNumber()/4))+excelDemoEntity.getNumber()));
                        //重量需要多个相加

                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getDcz())*0.35);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                        excelDemoEntity.setSheetnum("3");
                    }else if(goodsId.contains("HGHZM300g")||goodsId.contains("HGHZM300g")){
                        //核桃粉
                        excelDemoEntity.setHtf(String.valueOf((int)(Math.rint(excelDemoEntity.getNumber()/2))+excelDemoEntity.getNumber()));
//                        excelDemoEntity.setHtf(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getHtf())*0.3);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                        excelDemoEntity.setSheetnum("3");
                    }else if(goodsId.equals("HGMTC180g*7")){
                        excelDemoEntity.setG180(String.valueOf(excelDemoEntity.getNumber()*7));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*7*0.18);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGMTC500g*5")||goodsId.equals("HGMTC550G*5")){
                        excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()*5));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*5*0.5);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGMTC380G*5")){
                        excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber()*5));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*5*0.38);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGMTC500g*10")){
                        excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()*10));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*10*0.5);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGMTC380G*6")){
                        excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber()*6));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*6*0.38);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGMTC500g*6")){
                        excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()*6));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*6*0.5);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGMTC180G*10")){
                        excelDemoEntity.setG180(String.valueOf(excelDemoEntity.getNumber()*10));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*10*0.18);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGMTC380G*4")){
                        excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber()*4));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*4*0.38);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGMTC500G*7")){
                        excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()*7));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*7*0.5);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGMTCG500*3")){
                        excelDemoEntity.setU500(String.valueOf(excelDemoEntity.getNumber()*3));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*3*0.5);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGMTCG500*5")){
                        excelDemoEntity.setU500(String.valueOf(excelDemoEntity.getNumber()*5));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*5*0.5);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGMTCG500*6")){
                        excelDemoEntity.setU500(String.valueOf(excelDemoEntity.getNumber()*6));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*6*0.5);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGMTCG500*8")){
                        excelDemoEntity.setU500(String.valueOf(excelDemoEntity.getNumber()*6));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*6*0.5);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGMTCG500*10")){
                        excelDemoEntity.setU500(String.valueOf(excelDemoEntity.getNumber()*10));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*10*0.5);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGMTCD500*20")){
                        excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()*20));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*20*0.5);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGMTC500G*3")){
                        excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()*3));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*3*0.5);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGMTC380g*8")){
                        excelDemoEntity.setG380(String.valueOf(excelDemoEntity.getNumber()*8));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*8*0.38);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGMTC500G*8")){
                        excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()*8));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*8*0.5);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGMTC500G*2")){
                        excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()*2));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*2*0.5);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGMTCZH500g*15")){
                        excelDemoEntity.setG550(String.valueOf(excelDemoEntity.getNumber()*15));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*15*0.5);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goodsId.equals("HGKFT156g*10")){
                        excelDemoEntity.setG156(String.valueOf(excelDemoEntity.getNumber()*10));
                        excelDemoEntity.setWeight(excelDemoEntity.getNumber()*10*0.16);
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }
                    }else if(goods.contains("正品包邮 禾甘木糖醇10Kg 木糖醇食品 木糖醇糖 烘焙原料 代糖")){
                        excelDemoEntity.setG500(String.valueOf(excelDemoEntity.getNumber()));
                    }else if(goods.contains("正品包邮 禾甘木糖醇156g整箱 木糖醇食品 木糖醇代糖 便携装")){
                        excelDemoEntity.setG500(String.valueOf(excelDemoEntity.getNumber()));
                    }else if(goodsId.equals("HGGT25kgT")||goodsId.equals("HGGT25KG*1")){
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("中铁");
                            }
                        }
                        excelDemoEntity.setKg25(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getKg25())*27);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countCrlg(excelDemoEntity));
                        }

                        excelDemoEntity.setSheetnum("2");
                    }else if(goodsId.equals("HGGT25kgY")){

                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("中铁");
                            }
                        }
                        excelDemoEntity.setKgy25(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getKgy25())*27);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countCrlg(excelDemoEntity));
                        }
                        excelDemoEntity.setSheetnum("2");
                    }else if(goodsId.equals("HGGT2.3kgP")){
                        excelDemoEntity.setKg2(String.valueOf(excelDemoEntity.getNumber()));
                        //重量需要多个相加
                        excelDemoEntity.setExpress("申通");
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getKg2())*2.3);
//                        if(excelDemoEntity.getProvince()!=null){
//                            if(!("江苏省 浙江省 上海 安徽省".contains(province)) && excelDemoEntity.getWeight()>15){
//                                excelDemoEntity.setExpress("ems");
//                            }
//                        }

                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        excelDemoEntity.setSheetnum("2");
                    }else if(goodsId.equals("HGMTC500G*1MS")||goods.equals("1元抢购 禾甘木糖醇500g*1袋")){
                        //秒杀活动
                        excelDemoEntity.setG500(String.valueOf(excelDemoEntity.getNumber()));
                        excelDemoEntity.setWeight(Integer.parseInt(excelDemoEntity.getG500())*0.5);
                        if(excelDemoEntity.getProvince()!=null){
                            excelDemoEntity.setPostage(countPostage(excelDemoEntity.getProvince(),excelDemoEntity.getWeight(),excelDemoEntity.getExpress(),excelDemoEntity));
                        }else{
                            excelDemoEntity.setPostage(0);
                        }
                        if(excelDemoEntity.getNumber()==1){
                            excelDemoEntity.setG56("1");
                        }else{
                            excelDemoEntity.setG56("2");
                        }
                        if(excelDemoEntity.getProvince()!=null){
                            if(excelDemoEntity.getExpress().contains("EMS")||excelDemoEntity.getExpress().contains("ems")){
                                excelDemoEntity.setExpress("EMS");
                            }else{
                                excelDemoEntity.setExpress("申通");
                            }
                        }


                    }else{
                        //大小果糖，先不做
//                        excelDemoEntity.setExpress("");
                    }
                }



            }

            int number = excelDemoEntity.getNumber();


//            excelDao.save(excelDemoEntity); 保存早了

        }


        //进行合并订单操作。。就合并一个人同时拍的，传美合并的单。
//        for(int j = 0;j < list.size(); j ++){
//            //先找到重复的。
//            ExcelDemoEntity currentEntity = list.get(j);
//            //当前这个是，第一个。
//            if(currentEntity.getProvince()==null){
//                ExcelDemoEntity mergeEntity = new ExcelDemoEntity();
////                找到需要合并的那个。。没找到有单号的就一直往回溯呢。
//                for (int k = j;k >=0; k --){
//                    if(list.get(k).getProvince()!=null){
//                        mergeEntity = list.get(k);
//                        break;
//                    }
//                }
//
//                currentEntity.setPayDate(mergeEntity.getPayDate());
//                currentEntity.setName(mergeEntity.getName());
//                currentEntity.setOrdercode(mergeEntity.getOrdercode());
//                currentEntity.setProvince(mergeEntity.getProvince());
//                currentEntity.setExpress(mergeEntity.getExpress());
//                currentEntity.setMoney(currentEntity.getGoodsmoeny());
//
//                currentEntity.setProvince(mergeEntity.getProvince());
//                currentEntity.setPhone(mergeEntity.getPhone());
//                currentEntity.setAddress(mergeEntity.getAddress());
//                currentEntity.setBuyName(mergeEntity.getBuyName());
//
//                //如果第一个是沙琪玛，就把1,2位置换下。.
////                if(mergeEntity.getGoods().contains("沙琪玛")){
////                    ExcelDemoEntity a = new ExcelDemoEntity();
////                    a = mergeEntity;
////                    mergeEntity = currentEntity;
////                    mergeEntity.setMoney(a.getMoney());
////                    currentEntity = a;
////                    a.setMoney(a.getGoodsmoeny());
////                }
//
//
//
//                //把优惠放到第一个.
//                mergeEntity.setMoney(String.valueOf(Double.parseDouble(mergeEntity.getMoney()) - Double.parseDouble(currentEntity.getGoodsmoeny())));
//
//                if(fileName.contains("淘宝")){
//                    //则记录下当前这个，如果不是沙琪玛，2.3kg.25kg，则最后要从list中删除
//                    if(currentEntity.getGoods().contains("沙琪玛")){
//                        //不变，重新计算下重量和运费，还有价格就行。
////                        mergeEntity.setMoney(String.valueOf(Double.parseDouble(mergeEntity.getMoney()) - Double.parseDouble(currentEntity.getGoodsmoeny())));
////                        mergeEntity.setPostage(countPostage(mergeEntity.getProvince(),(mergeEntity.getWeight() + currentEntity.getWeight()),mergeEntity.getExpress(),mergeEntity));
//                        mergeEntity.setRemarks("禾甘");
//                    }else{
//
//                    }
//                }else{
//                    //则记录下当前这个，如果不是沙琪玛，2.3kg.25kg，则最后要从list中删除
//                    if(currentEntity.getGoods().contains("沙琪玛")){
//                        //不变，重新计算下重量和运费，还有价格就行。
////                        mergeEntity.setMoney(String.valueOf(Double.parseDouble(mergeEntity.getMoney()) - Double.parseDouble(currentEntity.getGoodsmoeny())));
////                        mergeEntity.setPostage(countPostage(mergeEntity.getProvince(),(mergeEntity.getWeight() + currentEntity.getWeight()),mergeEntity.getExpress(),mergeEntity));
//                        mergeEntity.setRemarks("禾甘");
//                    }else{
//
//
//
//
//                    }
//                }
//
//            }
//        }



        //计算单笔的，只计算单笔的金额。。单号必然是一样的。
        for(int p = 0;p < list.size(); p ++){

            ExcelDemoEntity orderlastEntity = list.get(p);

            if(orderlastEntity.getMoney()==null){
                orderlastEntity.setMoney("0");
            }
            orderlastEntity.setIsmoney(Double.parseDouble(orderlastEntity.getMoney()));//保持最初的金额。
            //京东金额误差.

//            if(Double.parseDouble(orderlastEntity.getGoodsmoeny())<0.8){
//                orderlastEntity.setGoodsmoeny("0");
//            }
//            if(Double.parseDouble(orderlastEntity.getGoodsmoeny())>Double.parseDouble(orderlastEntity.getMoney())){
//                orderlastEntity.setGoodsmoeny(orderlastEntity.getMoney());
//            }

            orderlastEntity.setTotalmoney(Double.parseDouble(orderlastEntity.getGoodsmoeny()));
            for (int q = p+1;q < list.size(); q ++){
                if(!orderlastEntity.getName().contains("删`-除")&&!list.get(q).getName().contains("删`-除")&&orderlastEntity.getIshedan()!=null&&list.get(q).getIshedan()!=null
                        &&orderlastEntity.getOrdercode() == list.get(q).getOrdercode()
                        &&!orderlastEntity.getIshedan().contains("单笔合单完成")&&!list.get(q).getIshedan().contains("单笔合单完成")
                        &&orderlastEntity.getIshedan().contains("单笔")&&list.get(q).getIshedan().contains("单笔合单")){
                    //一个订单第一个是总和的，
                    list.get(q).setMoney(list.get(q).getGoodsmoeny());
                    orderlastEntity.setMoney(orderlastEntity.getGoodsmoeny());
                    //有木糖醇就核对下金额？
//                    if(orderlastEntity.getSheetnum()=="1"||list.get(q).getSheetnum()=="1"){
                        orderlastEntity.setIshedan("单笔核对金额");
//                    }
                    orderlastEntity.setTotalmoney(orderlastEntity.getTotalmoney()+Double.parseDouble(list.get(q).getMoney()));
                    list.get(q).setIshedan("单笔合单完成");
//                  orderlastEntity.setMoney(String.valueOf(Double.parseDouble(orderlastEntity.getMoney())-Double.parseDouble(list.get(q).getGoodsmoeny())));

                }

            }

        }

        //循环核对单笔订单总金额。

        for(int p = 0;p < list.size(); p ++){

            ExcelDemoEntity moneyEntity = list.get(p);
            //不相等才修改，木糖醇 的金额。先修改木糖醇的。

            if(moneyEntity.getIshedan()!=null&&moneyEntity.getIshedan().contains("单笔核对金额")&&moneyEntity.getIsmoney()!=moneyEntity.getTotalmoney()){
                //修改下面子单的，木糖醇金额。

                for (int q = p+1;q < list.size(); q ++){
                    if(!moneyEntity.getName().contains("删`-除")&&!list.get(q).getName().contains("删`-除")&&moneyEntity.getIshedan()!=null&&list.get(q).getIshedan()!=null
                            &&moneyEntity.getOrdercode() == list.get(q).getOrdercode()){
                        //找到木糖醇的，减一下金额
                        if(moneyEntity.getSheetnum()=="1"){
                            moneyEntity.setMoney(String.valueOf(Double.parseDouble(moneyEntity.getMoney())+moneyEntity.getIsmoney()-moneyEntity.getTotalmoney()));
                            break;
                        }
                        if(list.get(q).getSheetnum()=="1"){
                            list.get(q).setMoney(String.valueOf(Double.parseDouble(list.get(q).getMoney())+moneyEntity.getIsmoney()-moneyEntity.getTotalmoney()));
                            break;
                        }


                    }

                }
            }


        }


        //再次循环合并 ，合并相同,人,电话,地址的多个订单，目前就一个吧，待完善.不同商品

        for(int m = 0;m < list.size(); m ++){

            ExcelDemoEntity currentlastEntity = list.get(m);


            //合并木糖醇
            if(currentlastEntity.getSheetnum()=="1"){
                for (int n = m+1;n < list.size(); n ++){
                    if(!list.get(n).getName().contains("删`-除")&&list.get(n).getSheetnum()=="1"&&currentlastEntity.getBuyName() == list.get(n).getBuyName()&&currentlastEntity.getName() == list.get(n).getName() && currentlastEntity.getPhone() == list.get(n).getPhone() && currentlastEntity.getAddress() == list.get(n).getAddress()){
                        deleteList.add(n);
                        list.get(n).setName(list.get(n).getName()+"删`-除");
                        //数量，邮费，钱，加到这个上面 mergeEntity.getU500()==null?0:Integer.parseInt(mergeEntity.getU500())
                        if(currentlastEntity.getG156()!=null||list.get(n).getG156()!=null){ currentlastEntity.setG156(String.valueOf((currentlastEntity.getG156()==null?0:Integer.parseInt(currentlastEntity.getG156())) + (list.get(n).getG156()==null?0:Integer.parseInt(list.get(n).getG156()))));}
                        if(currentlastEntity.getG200()!=null||list.get(n).getG200()!=null){currentlastEntity.setG200(String.valueOf((currentlastEntity.getG200()==null?0:Integer.parseInt(currentlastEntity.getG200())) + (list.get(n).getG200()==null?0:Integer.parseInt(list.get(n).getG200()))));}
                        if(currentlastEntity.getG300()!=null||list.get(n).getG300()!=null){currentlastEntity.setG300(String.valueOf((currentlastEntity.getG300()==null?0:Integer.parseInt(currentlastEntity.getG300())) + (list.get(n).getG300()==null?0:Integer.parseInt(list.get(n).getG300()))));}
                        if(currentlastEntity.getG500()!=null||list.get(n).getG500()!=null){currentlastEntity.setG500(String.valueOf((currentlastEntity.getG500()== null?0:Integer.parseInt(currentlastEntity.getG500())) + (list.get(n).getG500()==null?0:Integer.parseInt(list.get(n).getG500()))));}
                        if(currentlastEntity.getU500()!=null||list.get(n).getU500()!=null){currentlastEntity.setU500(String.valueOf((currentlastEntity.getU500()==null?0:Integer.parseInt(currentlastEntity.getU500())) + (list.get(n).getU500()==null?0:Integer.parseInt(list.get(n).getU500()))));}
                        if(currentlastEntity.getKgy25()!=null||list.get(n).getKgy25()!=null){currentlastEntity.setKgy25(String.valueOf((currentlastEntity.getKgy25()==null?0:Integer.parseInt(currentlastEntity.getKgy25())) + (list.get(n).getKgy25()==null?0:Integer.parseInt(list.get(n).getKgy25()))));}
                        if(currentlastEntity.getKg25()!=null||list.get(n).getKg25()!=null){currentlastEntity.setKg25(String.valueOf((currentlastEntity.getKg25()==null?0:Integer.parseInt(currentlastEntity.getKg25())) + (list.get(n).getKg25()==null?0:Integer.parseInt(list.get(n).getKg25()))));}

                        if(currentlastEntity.getG180()!=null||list.get(n).getG180()!=null){ currentlastEntity.setG180(String.valueOf((currentlastEntity.getG180()==null?0:Integer.parseInt(currentlastEntity.getG180())) + (list.get(n).getG180()==null?0:Integer.parseInt(list.get(n).getG180()))));}
                        if(currentlastEntity.getG380()!=null||list.get(n).getG380()!=null){ currentlastEntity.setG380(String.valueOf((currentlastEntity.getG380()==null?0:Integer.parseInt(currentlastEntity.getG380())) + (list.get(n).getG380()==null?0:Integer.parseInt(list.get(n).getG380()))));}
                        if(currentlastEntity.getG550()!=null||list.get(n).getG550()!=null){ currentlastEntity.setG550(String.valueOf((currentlastEntity.getG550()==null?0:Integer.parseInt(currentlastEntity.getG550())) + (list.get(n).getG550()==null?0:Integer.parseInt(list.get(n).getG550()))));}

                        if(currentlastEntity.getG56()!=null||list.get(n).getG56()!=null){
                            currentlastEntity.setG56(String.valueOf(((currentlastEntity.getG56()==null||currentlastEntity.getG56()=="")?0:Integer.parseInt(currentlastEntity.getG56())) + ((list.get(n).getG56()==null||list.get(n).getG56()=="")?0:Integer.parseInt(list.get(n).getG56()))));

                            if(Double.parseDouble(currentlastEntity.getG56())>=2&&Double.parseDouble(currentlastEntity.getG56())<=58){
                                currentlastEntity.setG56("2");
                            }
                            if(currentlastEntity.getG56().equals("0")){
                                currentlastEntity.setG56("");
                            }

                        }


                        //合计的时候把备注去下
                        currentlastEntity.setRemarks(currentlastEntity.getRemarks()==null?"":currentlastEntity.getRemarks()+list.get(n).getRemarks()==null?"":list.get(n).getRemarks());
//                    //普通时候多单拍送1沙琪玛。需要改成送1木糖醇
//                    Integer lll=(int)(Math.rint(Integer.parseInt(currentlastEntity.getG500()))/3);
//                    if(lll!=null&&lll!=0){
//                        currentlastEntity.setRemarks(Integer.toString(lll));
//                    }


                        currentlastEntity.setMoney(String.valueOf(Double.parseDouble(currentlastEntity.getMoney()==null?"0":currentlastEntity.getMoney()) + Double.parseDouble(list.get(n).getMoney()==null?"0":list.get(n).getMoney())));
                        currentlastEntity.setWeight(currentlastEntity.getWeight() + list.get(n).getWeight());
//                        currentlastEntity.setRemarks(currentlastEntity.getRemarks()+ list.get(n).getRemarks());
                        if(currentlastEntity.getKg25()!=null||currentlastEntity.getKgy25()!=null){
                            currentlastEntity.setPostage(countCrlg(currentlastEntity));
                        }else{
                            currentlastEntity.setPostage(countPostage(currentlastEntity.getProvince(),currentlastEntity.getWeight(),currentlastEntity.getExpress(),currentlastEntity));
                        }

                    }
                }
            }




            //合并无糖食品
            if(currentlastEntity.getSheetnum()=="3"){
                for (int n = m+1;n < list.size(); n ++){
                    if(!list.get(n).getName().contains("删`-除")&&list.get(n).getSheetnum()=="3"&&currentlastEntity.getBuyName() == list.get(n).getBuyName()&&currentlastEntity.getName() == list.get(n).getName() && currentlastEntity.getPhone() == list.get(n).getPhone() && currentlastEntity.getAddress() == list.get(n).getAddress()){
                        deleteList.add(n);
                        list.get(n).setName(list.get(n).getName()+"删`-除");
                        if(currentlastEntity.getRedbean()!=null||list.get(n).getRedbean()!=null){ currentlastEntity.setRedbean(String.valueOf((currentlastEntity.getRedbean()==null?0:Integer.parseInt(currentlastEntity.getRedbean())) + (list.get(n).getRedbean()==null?0:Integer.parseInt(list.get(n).getRedbean()))));}
                        if(currentlastEntity.getLongan()!=null||list.get(n).getLongan()!=null){currentlastEntity.setLongan(String.valueOf((currentlastEntity.getLongan()==null?0:Integer.parseInt(currentlastEntity.getLongan())) + (list.get(n).getLongan()==null?0:Integer.parseInt(list.get(n).getLongan()))));}
                        if(currentlastEntity.getWax()!=null||list.get(n).getWax()!=null){currentlastEntity.setWax(String.valueOf((currentlastEntity.getWax()==null?0:Integer.parseInt(currentlastEntity.getWax())) + (list.get(n).getWax()==null?0:Integer.parseInt(list.get(n).getWax()))));}
                        if(currentlastEntity.getS500()!=null||list.get(n).getS500()!=null){ currentlastEntity.setS500(String.valueOf((currentlastEntity.getS500()==null?0:Integer.parseInt(currentlastEntity.getS500())) + (list.get(n).getS500()==null?0:Integer.parseInt(list.get(n).getS500()))));}


                        if(currentlastEntity.getG56()!=null||list.get(n).getG56()!=null){
                            currentlastEntity.setG56(String.valueOf(((currentlastEntity.getG56()==null||currentlastEntity.getG56()=="")?0:Integer.parseInt(currentlastEntity.getG56())) + ((list.get(n).getG56()==null||list.get(n).getG56()=="")?0:Integer.parseInt(list.get(n).getG56()))));

                            if(Double.parseDouble(currentlastEntity.getG56())>=59){
                                currentlastEntity.setG56("2");
                            }
                            if(currentlastEntity.getG56().equals("0")){
                                currentlastEntity.setG56("");
                            }

                        }

                        //合计的时候把备注去下
                        currentlastEntity.setRemarks(currentlastEntity.getRemarks()==null?"":currentlastEntity.getRemarks()+list.get(n).getRemarks()==null?"":list.get(n).getRemarks());
                        currentlastEntity.setMoney(String.valueOf(Double.parseDouble(currentlastEntity.getMoney()==null?"0":currentlastEntity.getMoney()) + Double.parseDouble(list.get(n).getMoney()==null?"0":list.get(n).getMoney())));
                        currentlastEntity.setGoodsmoeny(String.valueOf(Double.parseDouble(currentlastEntity.getGoodsmoeny()) + Double.parseDouble(list.get(n).getGoodsmoeny())));
                        currentlastEntity.setWeight(currentlastEntity.getWeight() + list.get(n).getWeight());
                        currentlastEntity.setPostage(countPostage(currentlastEntity.getProvince(),currentlastEntity.getWeight(),currentlastEntity.getExpress(),currentlastEntity));

                    }
                }
            }


        }


        //计算单笔的，运费的订单金额，+ 运费。
        for(int p = 0;p < list.size(); p ++){

            ExcelDemoEntity orderlastEntity = list.get(p);

            for (int q = p+1;q < list.size(); q ++){
                if(!orderlastEntity.getName().contains("删`-除")&&!list.get(q).getName().contains("删`-除")
                        &&orderlastEntity.getBuyName() == list.get(q).getBuyName()&&orderlastEntity.getName() == list.get(q).getName() && orderlastEntity.getPhone() == list.get(q).getPhone() && orderlastEntity.getAddress() == list.get(q).getAddress()
                        ){
                    //先找木糖醇的，没有再说？
                    if(orderlastEntity.getSheetnum().equals("1")){
                        //第一个就是的话，String.valueOf(Double.parseDouble
//                        orderlastEntity.setMoney(String.valueOf(Double.parseDouble(orderlastEntity.getMoney())-Double.parseDouble(list.get(q).getGoodsmoeny())));
//                        list.get(q).setMoney(list.get(q).getGoodsmoeny());
                        list.get(q).setPostage(0.0);
                    }
                    if(list.get(q).getSheetnum().equals("1")){
//                        list.get(q).setMoney(String.valueOf(Double.parseDouble(orderlastEntity.getMoney())-Double.parseDouble(list.get(q).getGoodsmoeny())));
                        orderlastEntity.setPostage(0.0);
//                        orderlastEntity.setMoney(orderlastEntity.getGoodsmoeny());

                    }
                }

            }



        }

        //删除重复数据  xxx删不掉，算了，过滤重复数据吧，
//        for(int p = 0;p < deleteList.size(); p ++){
//            System.out.println(deleteList.get(p));
//            list.remove(deleteList.get(p));
//        }

//        //过滤删除数据
//        Iterator<ExcelDemoEntity> iter = list.iterator();
//        while(iter.hasNext()){
//            ExcelDemoEntity b = iter.next();
//            for(int p = 0;p < deleteList.size(); p ++){
//                if(b.getRemarks().equals("删除")){
//                    iter.remove();
//                }
//            }
//
//        }
        //最后一条条保存到数据库
        for (ExcelDemoEntity saveExcel : list) {
            if(saveExcel.getName()!=null&&!saveExcel.getName().contains("删`-除")){


//                //普通时候多单拍送1沙琪玛。需要改成送1木糖醇...如果一个人拍了 1000g 8袋就有问题。
//                if(saveExcel.getG500()!=null){
//                    Integer lll=(int)(Math.rint(Integer.parseInt(saveExcel.getG500()))/3);
//                    if(lll!=null&&lll!=0){
//                        saveExcel.setRemarks(Integer.toString(lll));
//                    }
//                }


                excelDao.save(saveExcel);
            }
        }



    }


    //计算运费
    public double countPostage(String province , double weight ,String express,ExcelDemoEntity currentlastEntity) {
        //根据省份+重量，先做简单的~
        //一区
        if("江苏省 浙江省 上海 安徽省".contains(province)){
            if(express.contains("申通")){
                if(weight < 2.6){
                    return 3.8;
                }else if(weight < 3.5){
                    return 6.8;
                }else{
                    //先四舍五入，然后+1kg
                    return 3.8 + Math.rint(weight);
                    //10kg以上注意下，手动看下,还有打多个面单。。后续完善。
                }
            }else{
                currentlastEntity.setExpress("EMS");
                if("安徽省".contains(province)){
                    return 5 + 2*Math.rint(weight);
                }else{
                    //江苏省 浙江省 上海
                    return 5 + Math.rint(weight);
                }
            }


            //二区
        }else if("江西省 福建省 山东省 北京 天津 湖南省 湖北省 河南省 河北省 广东省".contains(province)){
            if(express.contains("申通")){
                if(weight < 2.6){
                    return 4.8;
                }else if(weight < 3.3){
                    return 12.3;
                }else if(weight < 3.7){
                    return 13.8;
                }else{
                    //先四舍五入，然后+1kg
                    return 4.8 + 3*Math.rint(weight);
                    //10kg以上注意下，手动看下,还有打多个面单。。后续完善。
                }
            }else{
                currentlastEntity.setExpress("EMS");

                if("江西省 福建省 山东省 湖南省 湖北省 河南省".contains(province)){
                    if(weight<4.7){
                        return 5.5 + 2*Math.rint(weight);
                    }else{
                        return 8 + 3*Math.rint(weight);
                    }
                }else if("北京".contains(province)){
                    return 10 + 4*Math.rint(weight);
                }else{
                    //天津 河北省 广东省 河北省
                    if(weight<4.7){
                        return 6 + 2.5*Math.rint(weight);
                    }else{
                        return 8.5 + 3.5*Math.rint(weight);
                    }
                }

            }

        }else if("四川省 重庆 山西省 陕西省 贵州省 广西壮族自治区 黑龙江省 辽宁省 吉林省".contains(province)){
            if(express.contains("申通")){
                if(weight < 3){
                    return 5.5;
                }else if(weight < 3.3){
                    return 20.5;
                }else{
                    //先四舍五入，然后+1kg
                    return 5.5 + 6*Math.rint(weight);
                    //10kg以上注意下，手动看下,还有打多个面单。。后续完善。
                }
            }else{
                currentlastEntity.setExpress("EMS");
                if("四川省 重庆  贵州省 广西壮族自治区  辽宁省 ".contains(province)){
                    if(weight<4.7){
                        return 8 + 3*Math.rint(weight);
                    }else{
                        return 10.5 + 4.5*Math.rint(weight);
                    }
                }else if("山西省 陕西省".contains(province)){
                    if(weight<4.7){
                        return 6 + 2.5*Math.rint(weight);
                    }else{
                        return 8.5 + 3.5*Math.rint(weight);
                    }
                }else{
                    //黑龙江省 吉林省
                    if(weight<4.7){
                        return 8.5 + 4*Math.rint(weight);
                    }else{
                        return 12 + 6*Math.rint(weight);
                    }
                }

            }

        }else if("云南省 海南省 青海省 宁夏回族自治区 甘肃省 内蒙古自治区".contains(province)){
            if(express.contains("申通")){
                if(weight < 1){
                    return 10;
                }else if(weight < 1.3){
                    return 14;
                }else if(weight < 1.8){
                    return 18;
                }else if(weight < 2.5){
                    return 22;
                }else if(weight < 3.1){
                    return 26;
                }else if(weight < 4.1){
                    return 34;
                }else{
                    return 10 + 8*Math.rint(weight);
//                    if("海南省  宁夏回族自治区 甘肃省 内蒙古自治区".contains(province)){
//                        //发邮政
//                        currentlastEntity.setExpress("ems");
//                        if(weight<4.7){
//                            return 8 + 3*Math.rint(weight);
//                        }else{
//                            return 10.5 + 4.5*Math.rint(weight);
//                        }
//                    }else if("青海省".contains(province)){
//                        //发申通
//                        return 10 + 8*Math.rint(weight);
//                    }else{
//                        //云南省
//                        //发邮政
//                        currentlastEntity.setExpress("ems");
//                        if(weight<4.7){
//                            return 8.5 + 4*Math.rint(weight);
//                        }else{
//                            return 12 + 6*Math.rint(weight);
//                        }
//                    }

                }
            }else{
                currentlastEntity.setExpress("EMS");
                if("海南省  宁夏回族自治区 甘肃省 内蒙古自治区".contains(province)){
                    if(weight<4.7){
                        return 8 + 3*Math.rint(weight);
                    }else{
                        return 10.5 + 4.5*Math.rint(weight);
                    }
                }else if("青海省".contains(province)){
                    return 18.5 + 12*Math.rint(weight);
                }else{
                    //云南省
                    if(weight<4.7){
                        return 8.5 + 4*Math.rint(weight);
                    }else{
                        return 12 + 6*Math.rint(weight);
                    }
                }
            }

        }else{
            if(express.contains("申通")){
                if(weight < 1){
                    return 15;
                }else if(weight < 1.3){
                    return 21.5;
                }else if(weight < 1.8){
                    return 28;
                }else if(weight < 2.5){
                    return 34.5;
                }else if(weight < 3.1){
                    return 41;
                }else if(weight < 4.1){
                    return 47.5;
                }else{
                    return 15 + 13*Math.rint(weight);
                }
            }else{
                //新疆、西藏
                currentlastEntity.setExpress("EMS");
                return 18.5 + 12*Math.rint(weight);
            }
        }

    }

    //计算运费
    public double countCrlg(ExcelDemoEntity currentlastEntity) {
        if(currentlastEntity.getExpress().contains("EMS")){
            if("浙江省".contains(currentlastEntity.getProvince())){
                return currentlastEntity.getNumber()*30;
            }else{
                return currentlastEntity.getNumber()*31;
            }
        }else{
            //一区
            String province = currentlastEntity.getProvince();
            String city = currentlastEntity.getCity();
            String county = currentlastEntity.getCounty();
            if(province==null){
                province="";
            }
            if(city==null){
                city="";
            }
            if(county==null){
                county="";
            }
            if(city.length()>2){
                city = city.substring(0,2);
            }
            if(county.length()>2){
                county = county.substring(0,2);
            }
            CrlgDemoEntity crlgDemoEntity = new CrlgDemoEntity();

            List<CrlgDemoEntity> crlgList = crlgDao.queryCrlg(province,county);
            if(crlgList.size()>0){
                crlgDemoEntity = crlgList.get(0);
            }else{
                crlgList = crlgDao.queryCrlg(province,city);
                if(crlgList.size()>0){
                    crlgDemoEntity = crlgList.get(0);
                }
            }

            if(crlgList.size()>0){

                if(crlgDemoEntity.getPerMoney()*currentlastEntity.getWeight()*0.65 < crlgDemoEntity.getLowMoney()){
                    return crlgDemoEntity.getLowMoney();
                }else{
                    return crlgDemoEntity.getPerMoney()*currentlastEntity.getWeight()*0.65;
                }
//                return 0;
            }else{
                return 0;
            }

        }




    }

    //查询数据接口
    @Override
    public List<ExcelDemoEntity> queryList(Map<String, Object> map) {
        return excelDao.queryList(map);
    }

    //

    @Override
    public int queryTotal(Map<String, Object> map) {
        return excelDao.queryTotal(map);
    }

    @Override
    public void deleteAll() {
        excelDao.deleteAll();
    }

}
